package com.kawaiior.asoulworld.property;

import com.kawaiior.asoulworld.property.Properties.*;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Random;

public class PropertyUtil {

    public static Random random = new Random();

    public static final String propertyArray = "propertyArray";
    public static final String propertyLevelArray = "propertyLevelArray";

    public static final String propertyDesc = "property";

    private static final int propertyNumbers = 5;
    public static void main(String[] args) {
        System.out.println(Arrays.toString(getPropertyNums(4)));
    }

    public static Iproperty getIproperty(int type, int level){
        if (type == 0){
            return new PropertyStorm(level);
        }
        else if (type == 1){
            return new PropertyPierce(level);
        }
        else if (type == 2){
            return new PropertyExecute(level);
        }
        else if (type == 3){
            return new PropertyCritical(level);
        }
        else if (type == 4){
            return new PropertyHemo(level);
        }
        return null;
    }

    private static List<Integer> getPropertyList(){
        List<Integer> list = new ArrayList<>();
        for (int i = 0; i < propertyNumbers; i++) {
            list.add(i);
        }
        return list;
    }

    public static int[] getPropertyLevel(int length){
        if (length<=0)return new int[0];

        Random random = new Random();
        int[] ints = new int[length];
        for (int i = 0; i < ints.length; i++) {
            ints[i] = random.nextInt(3);
        }
        return ints;
    }

    public static int[] getPropertyNums(int num){
        if (num<=0)return new int[0];

        int[] ints = new int[num];

        Random random = new Random();
        List<Integer> list = getPropertyList();
        for (int i = 0; i < num; i++) {
            int k = random.nextInt(list.size());
            ints[i] = list.get(k);
            list.remove(k);
        }
        Arrays.sort(ints);
        return ints;
    }

}
